package thread;

public class ThreadDemo4 {
    public static void main(String[] args) {
//fn+home行首,fn+end行尾
        Thread t = new Thread() {
            // {}的意思是要定义一个类.
            //这个新的类继承自Thread,在这里可以定义类的属性和方法
            //这个地方最主要是用来重写run方法
            //此时啊还创建了子类的实例,但是不晓得子类叫什么名字

            @Override
            public void run() {
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        };

        t.start();
        while(true) {
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }

    }
}
